﻿namespace TC
{
    public class Foreach_blueprint : TranslateBlueprint
    {
        public override editor.cfg.blueprint.Node OnTranslate(Node node)
        {
            FlowNode t = node as FlowNode;
            editor.cfg.blueprint.Foreach re = new editor.cfg.blueprint.Foreach();
            re.id = t.id;

            Port p = t.graph.GetConnect(t.outputPorts["Finish"]);
            if (p != null)
            {
                re.complete = p.parent.id;
            }

            p = t.graph.GetConnect(t.outputPorts["I"]);
            if(p != null)
            {
                re.loopBody = p.parent.id;
            }

            p = t.graph.GetConnect(t.inputPorts["array"]);
            if(p != null)
            {
                re.array = new editor.cfg.blueprint.OutputPin() { nodeId = p.parent.id, pinName = p.name };
            }

            return re;
        }
    }
}
